package com.nuit.cxl;

import java.lang.reflect.Field;
import java.lang.reflect.Method;

public class Test01 {

    public static void main(String[] args) throws ClassNotFoundException, NoSuchMethodException {
        Person person = new Person();
        Class c1 = person.getClass();
        c1.getName();

        Class c2 = Class.forName("com.nuit.cxl.Person");

        System.out.println(c2.getName());
        System.out.println(c2.getClass());
        //.sout

//        Field[] fields =  c1.getFields();
//        for (Field field : fields) {
//            System.out.println("getFields:" + field.getName());
//        }
//        Field[] fields2 = c2.getDeclaredFields();
//        for (Field field : fields2) {
//            System.out.println("getDeclaredFields:" + field.getName());
//        }

//        Method getName = c1.getMethod("getName", null);
//        System.out.println(getName);
//        Method setName = c1.getMethod("setName", String.class);
//        System.out.println(setName);

        Method method3 = c1.getDeclaredMethod("toString", String.class);

        Method[] declaredMethods = c1.getDeclaredMethods();
        for (Method method : declaredMethods) {
            System.out.println("getDeclaredMethods: " + method);
        }

        Method[] methods = c1.getMethods();
        for (Method method : methods) {
            System.out.println("getMethods:" + method);
        }

    }



}
